﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PeriodConflictFinder
{
    public class DateRange
    {
        public DateRange(DateTime dtStart, DateTime dtEnd)
        {
            if (dtEnd <= dtStart)
            {
                throw new ArgumentException("End date must be after the start date");
            }
            this.startTime = dtStart;
            this.endTime = dtEnd;
        }
        public DateTime startTime { get; set; }
        public DateTime endTime { get; set; }

        public override string ToString()
        {
            return string.Format("From : {0}:{1}  To : {2}:{3}", this.startTime.Hour, this.startTime.Minute.ToString().PadLeft(2,'0'), this.endTime.Hour, this.endTime.Minute.ToString().PadLeft(2,'0'));
        }
        public bool Intersects(DateRange range)
        {
            if (this.startTime >= range.startTime && this.endTime <= range.endTime)
                return true;
            else
                return false;
        }
    }
}
